package Offer.offer2016;
//O(nlogn)�㷨�����ܿ�����剑指offer
public class Test32 
{

	public static void main(String[] args) 
	{
		System.out.println(numberOf1(1));

	}
    public static int numberOf1(int n)
    {
    	if(n<1)
    	{
    		return 0;
    	}
    	int count=0;
    	for(int i=1;i<=n;i++)
    	{
    		count+=number(i);
    	}
    	return count;
    }
    public static int number(int n)
    {
    	int number=0;
    	while(n!=0)
    	{
    		if(n%10==1)
    		{
    			number++;
    		}
    		n=n/10;	
    	}
    	return number;
    }
}
